package test.service;

import test.testcase.dao.UserDao;
import test.user.user;
import test.utils.JsonResult;

public class ServiceUser {
	
	public static user getUser(String userid) {
		JsonResult result = UserDao.getUser(userid);
		user user = new user();
		user.setUserid(userid);
		user.setUsername(result.read("data[0].username").toString());
		user.setPwd(result.read("data[0].pwd").toString());
		return user;
	}
	
	public static user getUserByUserName(String username) {
		JsonResult result = UserDao.getUserByUserName(username);
		user user = new user();
		if (result.read("data[0].id") == null || result.read("data[0].id").toString() == null) {
			return null;
		}
		user.setUserid(result.read("data[0].id").toString());
		user.setUsername(result.read("data[0].username").toString());
		user.setPwd(result.read("data[0].pwd").toString());
		return user;
	}

}
